package com.ruoyi.platform.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.platform.domain.Staffs;
import com.ruoyi.platform.service.IStaffsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台工作人员Controller
 * 
 * @author ruoyi
 * @date 2025-10-21
 */
@RestController
@RequestMapping("/platform/staffs")
public class StaffsController extends BaseController
{
    @Autowired
    private IStaffsService staffsService;

    /**
     * 查询平台工作人员列表
     */
    @PreAuthorize("@ss.hasPermi('platform:staffs:list')")
    @GetMapping("/list")
    public TableDataInfo list(Staffs staffs)
    {
        startPage();
        List<Staffs> list = staffsService.selectStaffsList(staffs);
        return getDataTable(list);
    }

    /**
     * 导出平台工作人员列表
     */
    @PreAuthorize("@ss.hasPermi('platform:staffs:export')")
    @Log(title = "平台工作人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Staffs staffs)
    {
        List<Staffs> list = staffsService.selectStaffsList(staffs);
        ExcelUtil<Staffs> util = new ExcelUtil<Staffs>(Staffs.class);
        util.exportExcel(response, list, "平台工作人员数据");
    }

    /**
     * 获取平台工作人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:staffs:query')")
    @GetMapping(value = "/{staffId}")
    public AjaxResult getInfo(@PathVariable("staffId") String staffId)
    {
        return success(staffsService.selectStaffsByStaffId(staffId));
    }

    /**
     * 新增平台工作人员
     */
    @PreAuthorize("@ss.hasPermi('platform:staffs:add')")
    @Log(title = "平台工作人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Staffs staffs)
    {
        return toAjax(staffsService.insertStaffs(staffs));
    }

    /**
     * 修改平台工作人员
     */
    @PreAuthorize("@ss.hasPermi('platform:staffs:edit')")
    @Log(title = "平台工作人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Staffs staffs)
    {
        return toAjax(staffsService.updateStaffs(staffs));
    }

    /**
     * 删除平台工作人员
     */
    @PreAuthorize("@ss.hasPermi('platform:staffs:remove')")
    @Log(title = "平台工作人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{staffIds}")
    public AjaxResult remove(@PathVariable String[] staffIds)
    {
        return toAjax(staffsService.deleteStaffsByStaffIds(staffIds));
    }
}
